package com.loong.web.suppert.handle;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.loong.web.suppert.collection.vo.ResultVo;
import com.loong.web.suppert.collection.vo.ResultVoFactory;
import com.loong.web.suppert.exception.PublishException;

/**
 * 接口异常处理器
 * 
 * @author 张成轩
 */
@ControllerAdvice
public class RestExceptionHandler {

	/**
	 * 接口时异常处理
	 * 
	 * @param ex 异常对象
	 * @return vo
	 */
	@ExceptionHandler(PublishException.class)
	@ResponseBody
	public ResultVo<?> exceptionHandler(PublishException ex) {

		return ResultVoFactory.fail(ex.getMessage());
	}
}
